package org.example.zcn2022.service.Impl;

import com.alibaba.fastjson.JSONObject;
import org.example.zcn2022.entity.ZcnStaff;
import org.example.zcn2022.mapper.StaffMapper;
import org.example.zcn2022.model.bo.StaffSetStaffInfoInputBO;
import org.example.zcn2022.service.StaffService;
import org.example.zcn2022.service.ZcnStaffService;
import org.fisco.bcos.sdk.transaction.model.dto.TransactionResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ZcnStaffServiceImpl implements ZcnStaffService {
    @Autowired
    public StaffMapper staffMapper;

    @Autowired
    public StaffService staffService;

    @Override
    public List<ZcnStaff> getZcnStaffs() {
        return staffMapper.getZcnStaffs();// 调用员工映射接口的获取员工列表方法
    }


    @Override
    public String setZcnStaff(ZcnStaff zcnStaff) throws Exception {
        staffMapper.setZcnStaff(zcnStaff);

        JSONObject jsonObject = new JSONObject();
        StaffSetStaffInfoInputBO input = new StaffSetStaffInfoInputBO();
        input.setStaffNumber(zcnStaff.getStaffNumber());
        input.setStaffName(zcnStaff.getStaffName());
        TransactionResponse transactionResponse = staffService.setStaffInfo(input);// 调用员工服务接口的设置员工信息方法
        jsonObject.put("data", transactionResponse);

        return jsonObject.toString();
    }

}
